<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">Search Github Users</h3>
    <div>
      <input type="text" placeholder="enter the name you search" v-model.lazy="inputVal"/>
      <button @click="searchFn">Search</button>
      <br>
      <strong style="color: red;font-size: 12px" v-show="this.$store.state.flag">用户名不能为空</strong>
    </div>
  </section>
</template>

<script>
import {mapActions} from 'vuex'
export default {
  name: "search",
  computed: {
    inputVal: {
      get () {
        return this.$store.state.name
      },
      set (newVal) {
        this.$store.commit('dataName', newVal)
      }
    },
  },
  methods:{
    ...mapActions({
      searchFn:'searchFn',
    }),
  }
}
</script>

<style scoped>

</style>
